package ui.components.renderlist
{
	import flash.utils.Dictionary;
	import flash.utils.getQualifiedClassName;
	
    public class RendererPool
    {
        private static var _renderPool:Dictionary = new Dictionary();

        public function RendererPool()
        {
            return;
        }

        public static function borrowRenderer(param1:Class):AbstractRenderer
        {
            var renderers:Array;
            var renderer:AbstractRenderer;
            var rendererClass:* = param1;
            var className:* = getQualifiedClassName(rendererClass);
            if (_renderPool[className] == undefined)
            {
                _renderPool[className] = [];
            }
            renderers = _renderPool[className] as Array;
            if (renderers != null && renderers.length > 0)
            {
                renderer = renderers.pop();
            }
            else
            {
                try
                {
                    renderer = new rendererClass;
                }
                catch (error:Error)
                {
                    renderer = new DefaultRenderer();
                }
            }
            return renderer;
        }

        public static function returnRenderer(param1:AbstractRenderer) : void
        {
            param1.clear();
            var _loc_2:* = _renderPool[param1.valueTypeName] as Array;
            if (_loc_2 != null)
            {
                _loc_2.push(param1);
            }
            return;
        }
    }
}
